package ar.com.digitalbricks.fwk.hbm;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.opensymphony.xwork2.ActionSupport;

public abstract class ActionTransactionSupportAbstract extends ActionSupport {
	private static SessionFactory sessionFactory;

	protected Transaction getCurrentTransaction() {
		Session session = this.getSessionFactory().getCurrentSession();
		if (!session.getTransaction().isActive()){
			session.beginTransaction();
		}
		return session.getTransaction();
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		ActionTransactionSupportAbstract.sessionFactory = sessionFactory;
	}

}